package com.mall.controller;

import com.mall.pageResult.PageResult;
import com.mall.pojo.CmsSubject;
import com.mall.service.CmsSubjectService;
import com.mall.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService cmsSubjectService;

    //获取全部商品专题
    @GetMapping("/listAll")
    public Result<List<CmsSubject>> listAll() {
        List<CmsSubject> list = cmsSubjectService.listAll();
        return Result.success(list, "操作成功");
    }

    /**
     * 根据专题名称分页获取商品专题
     * @param pageNum
     * @param pageSize
     * @param keyword
     * @return
     */
    @GetMapping("/list")
    public Result<PageResult<CmsSubject>> list(@RequestParam(value = "pageNum",required = false) Integer pageNum,
                                               @RequestParam(value = "pageSize",required = false) Integer pageSize,
                                               @RequestParam(required = false) String keyword){
        PageResult<CmsSubject> result = cmsSubjectService.list(pageNum,pageSize,keyword);
        return Result.success(result,"操作成功");
    }

}
